package DEMO;

import org.junit.jupiter.api.Test;

/**
 * @author Lzm
 * @version 1.0
 */
public class demo2 {
  @Test
  public void test(){
    int count = 0;
    for (int i = 1 ; i <= 3154354 ; i ++){
      if (isDouble(i)){
        System.out.println(i);
        count++;
        continue;
      }
    }
    System.out.println(count);
  }

  public boolean isDouble(int n){
    int count = 1;
    int num = n;
    if (n <= 9){
      return false;
    }
    while(num > 9){
      count++;
      num /= 10;
    }
    if (count % 2 != 0){
      return false;
    }
    int[] nums = new int[count];
    num = n;
    for (int i = count - 1; i >= 0  ; i--){
      nums[i] = num % 10;
      num /= 10;
    }
    int sum1 = 0;
    int sum2 = 0;
    for (int i = 0 ; i < count / 2 ; i ++){
      sum1 += nums[i];
      sum2 += nums[i + count / 2];
    }
    if (sum1 == sum2){
      return true;
    }
    else{
      return false;
    }
  }
}
